﻿using System.Data;
using Navigant.Infrastructure.Cases;
using Navigant.Infrastructure.EntityFactoryFramework;
using Navigant.Infrastructure.Helpers;
using Navigant.Model.PreservationNotices;

namespace Navigant.Infrastructure.Repositories
{
    public class PreservationNoticeBatchFactory : IEntityFactory<PreservationNoticeBatch>
    {
        #region FieldNames

        private class FieldNames
        {
            public static string Id = "SendNoticeQueueID";
            public static string SiteUrl = "SiteURL";
            public static string NewSiteUrl = "NewSiteURL";
            public static string NoticeId = "NoticeID";
            public static string PreservationCriteria = "PreservationCriteria";
            public static string FromAddress = "FromAddress";
            public static string Created = "Created";
            public static string ExtraCriteriaName = "ExtraCriteriaName";
            public static string ExtraCriteriaValue = "ExtraCriteriaValue";
        }

        #endregion

        #region IEntityFactory<PreservationNoticeBatch> Members

        public PreservationNoticeBatch BuildEntity(IDataReader reader, ICase parentCase)
        {
            return new PreservationNoticeBatch(DataHelper.GetInteger(reader[FieldNames.Id]),
                DataHelper.GetDateTime(reader[FieldNames.Created]),
                DataHelper.GetInteger(reader[FieldNames.NoticeId]),
                DataHelper.GetEnumValue<PreservationNoticeCriteria>(reader[FieldNames.PreservationCriteria]),
                parentCase,
                DataHelper.GetString(reader[FieldNames.FromAddress]),
                DataHelper.GetString(reader[FieldNames.ExtraCriteriaName]),
                DataHelper.GetString(reader[FieldNames.ExtraCriteriaValue])
                );
        }

        public void LoadExtendedProperties(IDataReader reader, PreservationNoticeBatch entity)
        {
        }

        #endregion
    }
}
